if __name__ == '__main__':
    # 外部启动django的方法
    import sys, os
    from django.core.wsgi import get_wsgi_application

    base_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
    sys.path.append(base_dir)
    os.environ['DJANGO_SETTINGS_MODULE'] = 'drf_movie_rimi.settings'
    application = get_wsgi_application()

    from rest_framework import serializers
    from mytest.models import Mytest


    class MyTestSerializer(serializers.ModelSerializer):



        class Meta:
            model = Mytest
            fields = ("name", 'age')


    data = MyTestSerializer(data={'name': 'model', 'age': 54})
    data.is_valid()
    data.save()
